<?php
/**
 * Created by PhpStorm.
 * User: liuxiaojie
 * Date: 2019-03-10
 * Time: 22:51
 */

namespace app\ops\controller;

use app\model\Config;
use app\service\SystemService;
use think\Request;

class System extends Base

{
    public $systemService;
    function __construct(Request $request = null, SystemService $systemService)
    {
        parent::__construct($request);
        $this->systemService = $systemService;
    }

    function index()
    {
        $data = $this->systemService->config([]);
        $this->assign('list', $data);
        return $this->fetch();
    }

    function edit($id = 0)
    {
        $data = db('config')->where(['id'=> $id])->find();
//        dump($data);
        $this->assign('data', $data);
        return $this->fetch();
    }
    function editSave()
    {
        $post = Request::instance()->post();
        if($post)
        {
            db('config')->update($post);
        }
        return success([]);
    }

}